package com.xbongbong.saas.enums.product;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.enums.FieldTypeEnum;
import com.xbongbong.paas.enums.ScreenTypeEnum;
import com.xbongbong.saas.enums.SelectProductEnum;
import com.xbongbong.saas.enums.SetTypeEnum;
import com.xbongbong.saas.enums.ShowTypeEnum;
import com.xbongbong.saas.enums.subform.ContractProductSubFormEnum;
import lombok.Getter;

/**
 * 用于自定义报表合同产品和合同关联的时候使用
 * @author 梁鲁江
 * @version v1.0
 * @date 2020/12/9 14:02
 * @since v1.0
 */
@Getter
public enum ContractProductBIEnum {
    // 产品id
//    PRODUCT(SelectProductEnum.PRODUCT.getAttr(),ContractProductEnum.PRODUCT),
    //编号和名称对外不提供data外的字段
    PRODUCT_NO(ContractProductSubFormEnum.PRODUCT_NO.getDataAttr(),ContractProductSubFormEnum.PRODUCT_NO.getDataAttr(),SelectProductEnum.PRODUCT_NO.getI18nAttrName(),SelectProductEnum.PRODUCT_NO.getFieldType(),SetTypeEnum.DISABLE_ALL.getCode(),0,0,ShowTypeEnum.ALL.getCode(),1,1, ScreenTypeEnum.SCREEN_GROUP.getType()),
    PRODUCT_NAME(ContractProductSubFormEnum.PRODUCT_NAME.getDataAttr(),ContractProductSubFormEnum.PRODUCT_NAME.getDataAttr(),SelectProductEnum.PRODUCT_NAME.getI18nAttrName(),SelectProductEnum.PRODUCT_NAME.getFieldType(),SetTypeEnum.DISABLE_ALL.getCode(),0,0,ShowTypeEnum.ALL.getCode(),1,1, ScreenTypeEnum.SCREEN_GROUP.getType()),
    PRICE(ContractProductSubFormEnum.PRICE.getDataAttr(),ContractProductSubFormEnum.PRICE.getDataAttr(),ContractProductEnum.PRICE, ScreenTypeEnum.SCREEN_GROUP.getType()),
    DISCOUNT(ContractProductSubFormEnum.DISCOUNT.getDataAttr(),ContractProductSubFormEnum.DISCOUNT.getDataAttr(),ContractProductEnum.DISCOUNT, ScreenTypeEnum.SCREEN_GROUP.getType()),
    SELLING_PRICE(ContractProductEnum.SELLING_PRICE.getAttr(),ContractProductEnum.SELLING_PRICE.getAttr(),ContractProductEnum.SELLING_PRICE, ScreenTypeEnum.SCREEN_GROUP.getType()),
    NUM(ContractProductSubFormEnum.PRODUCT_NUM.getDataAttr(),ContractProductSubFormEnum.PRODUCT_NUM.getDataAttr(),ContractProductEnum.NUM, ScreenTypeEnum.SCREEN_GROUP.getType()),
    MEMO(ContractProductSubFormEnum.MEMO.getDataAttr(),ContractProductSubFormEnum.MEMO.getDataAttr(),ContractProductEnum.MEMO, ScreenTypeEnum.SCREEN_SHOW.getType()),
    UNIT(ContractProductEnum.UNIT.getAttr(),ContractProductEnum.UNIT.getAttr(),ContractProductEnum.UNIT, ScreenTypeEnum.SCREEN_GROUP.getType()),
    SUBTOTAL(ContractProductEnum.SUBTOTAL.getAttr(),ContractProductEnum.SUBTOTAL.getAttr(),ContractProductEnum.SUBTOTAL, ScreenTypeEnum.SCREEN_GROUP.getType()),
    ;
    /**
     * 英文名称
     */
    private String attr;
    /**
     * 英文名称
     */
    private String saasAttr;
    /**
     * 中文名称
     */
    private String attrName;
    /**
     * 字段类型，详见
     *
     * @see FieldTypeEnum
     */
    private Integer fieldType;
    /**
     * 重命名、判重、启用必填等权限
     */
    private Integer setType;
    /**
     * 模板设计阶段字段是否允许编辑
     * 1：允许编辑
     * 0：不允许编辑
     */
    private Integer designEditable;
    /**
     * 字段是否显示在模板设计界面
     * 1：不显示
     * 0：显示
     */
    private Integer editHide;
    /**
     * 字段在各个界面（新建、编辑、列表、详情）的展现形式
     */
    private Integer showType;
    /**
     * 字段在各个界面是否可见(启用)
     * 1：可见
     * 0：不可见
     * 注：字段在具体页面的可见性需要用属性和showType联合判断，在visible=1的情况下判断showType
     */
    private Integer visible;
    /**
     * 字段是否必填
     * 1：必填
     * 0：不必填
     */
    private Integer required;

    /**
     * 筛选类型
     * @see ScreenTypeEnum
     */
    private Integer screenType;


    ContractProductBIEnum(String attr,String saasAttr,ContractProductEnum contractProductEnum,Integer screenType) {
        this.attr = attr;
        this.saasAttr = contractProductEnum.getSaasAttr();
        this.attrName = contractProductEnum.getAttrName();
        this.fieldType = contractProductEnum.getFieldType();
        this.setType = contractProductEnum.getSetType();
        this.designEditable = contractProductEnum.getDesignEditable();
        this.editHide = contractProductEnum.getEditHide();
        this.showType = contractProductEnum.getShowType();
        this.visible = contractProductEnum.getVisible();
        this.required = contractProductEnum.getRequired();
        this.screenType = screenType;
    }

    ContractProductBIEnum(String attr,String saasAttr, String attrName, Integer fieldType, Integer setType, Integer designEditable, Integer editHide, Integer showType, Integer visible, Integer required,Integer screenType) {
        this.attr = attr;
        this.saasAttr = saasAttr;
        this.attrName = attrName;
        this.fieldType = fieldType;
        this.setType = setType;
        this.designEditable = designEditable;
        this.editHide = editHide;
        this.showType = showType;
        this.visible = visible;
        this.required = required;
        this.screenType = screenType;
    }

    public String getAttrName() {
        return I18nMessageUtil.getMessage(attrName);
    }
}
